package com.appkubes.mall.restful.application.order.goods.service.impl;

import com.appkubes.common.utils.data.date.DateUtils;
import com.appkubes.common.utils.data.string.UUIDUtils;
import com.appkubes.mall.core.entity.MallOrderGoods;
import com.appkubes.mall.core.service.impl.BaseMallOrderGoodsServiceImpl;
import com.appkubes.mall.restful.application.order.goods.service.OrderGoodsService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class OrderGoodsServiceImpl extends BaseMallOrderGoodsServiceImpl implements OrderGoodsService {


    public List<MallOrderGoods> getOrderGoodsByOrderKey(String orderKey) {
        return getOrderGoodsByOrderKey(orderKey, null);
    }

    public List<MallOrderGoods> getOrderGoodsByOrderKey(String orderKey, Integer type) {
        MallOrderGoods queryEntity = new MallOrderGoods();
        queryEntity.setOrderKey(orderKey);
        queryEntity.setType(type);
        return this.selectListByEntity(queryEntity);
    }


    public Boolean add(MallOrderGoods model) {
        model.setOrdergoodsKey(UUIDUtils.getUUID());
        model.setCreateTime(DateUtils.DateToTimestamp(new Date()));
        model.setUpdateTime(DateUtils.DateToTimestamp(new Date()));
        return this.save(model);
    }


}
